package com.tedu.checkIn.controller;

import com.tedu.checkIn.pojo.dto.BelongingsParam;
import com.tedu.checkIn.pojo.dto.BelongingsQuery;
import com.tedu.checkIn.pojo.vo.BelongingsVO;
import com.tedu.checkIn.service.BelongingsService;
import com.tedu.common.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/v1/checkIn/belongings/")
public class BelongingsController {
    @Autowired
    BelongingsService belongingsService;

    @PostMapping("save")
    public JsonResult saveBelongings(BelongingsParam belongingsParam) {
        log.debug("保存个人物品，参数={}",belongingsParam);
        belongingsService.saveBelongings(belongingsParam);
        return JsonResult.ok();
    }

    @GetMapping("select")
    public JsonResult selectBelongings(BelongingsQuery belongingsQuery) {
        log.debug("保存个人物品，参数={}",belongingsQuery);
        List<BelongingsVO> list=belongingsService.selectBelongings(belongingsQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/delete/{id}")
    public JsonResult deleteBed(@PathVariable Integer id){
        log.debug("删除床位，参数={}",id);
        belongingsService.deleteBed(id);
        return JsonResult.ok();
    }
}
